/*import 'babel-polyfill';
import axios from 'axios';
import qs from 'qs';



//axios.defaults.timeout = 5000;
axios.defaults.withCredentials = true;  //默认跨越
axios.defaults.headers['Content-Type'] = 'multipart/form-data';
axios.defaults.headers['X-Requested-With'] = 'XMLHttpRequest';
//axios.defaults.baseURL = 'http://10.0.66.88:8080/ekp/';

//axios.defaults.baseURL = 'http://172.25.47.7:9090/yhcs/';//廖凯本地
//axios.defaults.baseURL = 'http://10.0.140.123:9080/';//内网
//axios.defaults.baseURL = 'http://10.0.66.88:8080/ekp/';//内网


//axios.interceptors.request.use((config) => {
//		if (sessionStorage.getItem("token")) {
//      config.headers.Authorization = `${sessionStorage.getItem("token")}`;
//  }
//  return config;
//},(error) =>{
//  return Promise.reject(error);
//});



axios.interceptors.response.use((res) =>{
    if(res.status != '200'){
    		return Promise.reject(res);
    }
    return  Promise.resolve(res.data);
}, (error) => {
    console.log("network error");
    return Promise.reject(error);
});

*/

const baseUrl = 'http://10.0.140.123:9080';

export default (Vue)=>{
	
	Vue.prototype.http = {
		
		post: (url,data,callback)=>{
			Vue.http.post(
				baseUrl+url,
				data.data,
				{headers:{
					'Content-Type':'application/json',
					'X-Requested-With':'XMLHttpRequest'
				}}
			).then((res)=>{
				callback(res.body);
			})			
		},
		fdpost: (url,params,callback)=>{
			Vue.http.post(
				baseUrl+url,
				params.data,
				{headers:{
					'Content-Type':'application/json',
					'X-Requested-With':'XMLHttpRequest'
				}}
			).then((res)=>{
				callback(res.body);
			})
		},
		/*fdpost: (url,params,callback)=>{
			let formData = new FormData();
			formData.append('json', JSON.stringify(params.data));
			let options = {method:'post', url, data:formData};
			axios(options).then((redata) => {
				callback(redata);
			},(err)=>{
				callback({err,success:false});
			})
		},
		upload: (url,params,callback,file)=>{
			let formData = new FormData();
			formData.append('json', JSON.stringify(params.data));
			formData.append('chunk','0');
			formData.append('chunks','1');
			formData.append('file',file,file.name)
			console.log(formData.get('file'));
			let options ={method:'post',url,data:formData}
			axios(options).then((res)=>{
				console.log(res);
				callback(res);
			},(err)=>{
				callback({err,success:false});
			})
		},
		delete: (url,callback)=>{
			axios({ method:'delete', url}).then((redata) => {
				callback(redata);
			},(err)=>{
				callback({err,success:false});
			})
		},
		
		put: (url,data,callback)=>{
			axios({ method:'put', url, data }).then((redata) => {
				callback(redata);
			},(err)=>{
				callback({err,success:false});
			})
		}*/
		
	};
	
};